#include <windows.h>
#include <stdio.h>

#include <compress.h>
#include <mTestUnit.h>

void T_huffman( void * ptr )
{
	mTestCase * TestCase = (mTestCase *) ptr;
	unsigned char phrase[80];
    unsigned char * compresse;
	unsigned char * data;

	int taille_comp, taille_orig;

	strcpy( phrase, "uuuuuuuuuuuuvvvvvvvvvvvvvvvvvvwwwwwwwxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyy" );
  
	taille_orig = (int) strlen( phrase ) + 1;
	taille_comp = huffman_compress( phrase, &compresse, taille_orig );

	mAssertIntEquals( TestCase, taille_orig, 73, "Compress taille original" ); 
	mAssertIntEquals( TestCase, taille_comp, 282, "Compress taille compress" );

	taille_orig = huffman_uncompress( compresse, &data );

	mAssertIntEquals( TestCase, taille_orig, 73, "Uncompress taille original" ); 
	mAssertIntEquals( TestCase, taille_comp, 282, "Uncompress taille compress" );

	mAssertStrEquals( TestCase, data, phrase, "huffman_uncompress data" );
}
